WO 2007/144197 A1 describes an autofocus device which images into the sample a modulation object that is intensity-modulated periodically along one direction, and which generates an autofocus signal from the image of the modulation object. Embodiments of the claimed invention improve upon such known devices.